<template>
	<view class="box">
		<view class="top">
			<u-navbar :is-back="true" title="我的兑换" :border-bottom="false"></u-navbar>
		</view>
		<view class="listbox">
			<view class="item" v-for="item in list" :key="item.id" @click="goPage(item.id)">
				<view class="pic" v-if="item.point_goods">
					<image :src="item.point_goods.images_format[0]" mode="widthFix" style="width: 260rpx;"></image>
				</view>
				<view class="name">
					{{item.point_goods.name}}
				</view>
				<view class="time">
					{{item.created_at}}
				</view>
				<view class="point">
					兑换积分:{{item.pay_point}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		myPointList
	} from '@/api/index.js'
	import baseUrl from '@/config/config.js'
	import { tiao } from '../../utils/common'; 
	export default {
		data() {
			return {
				list: [],
				page: 1,
				flag:false
			};
		},
		onLoad() {
			this.init()
		},
		onReachBottom() {
			if(this.flag){
				this.init()
			}
		},
		methods: {
			init() {
				
				myPointList({
					page:this.page
				}).then(res => {
					console.log("我的订单", res);
					if(res.last_page>res.page){
						this.page++
						this.flag = true
					}else{
						this.flag = false
					}
					res.list.forEach(item=>{
						this.list.push(item)
					})
				})
			},
			goPage(id){
				tiao('/other/exchangeDetail/exchangeDetail',{id})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.listbox{
		display: flex;
		flex-wrap: wrap;
		width: 710rpx;
		margin: 20rpx auto;
		box-sizing: border-box;
		justify-content: space-between;
		padding: 20rpx;
		.item{
			width: 300rpx;
			min-height: 250rpx;
			border-radius: 20rpx;
			overflow: hidden;
			background-color: #fff;
			box-shadow: 0 0 3rpx rgba(255, 0, 0, 0.3);
			padding: 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			.name{
				font-size: 32rpx;
				color: #333;
			}
			.time{
				font-size: 24rpx;
				color: #666;
			}
			.point{
				color: #f5cf34;
			}
		}
	}
</style>